package auto.app.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum  AssertMethodsType {
    GT(">","大于"),
    GTE(">=","大于等于"),
    EQ("=","等于"),
    NOEQ("!=","不等于"),
    EX("existence","存在"),
    NOEX("!existence","不存在"),
    LT("<","小于"),
    LTE("<=","小于等于"),
    CONTAIN("contain","包含"),
    NOCONTAIN("nocontain","不包含"),
    ISEMPTY("isempty","为空"),
    ISNOTEMPTY("isnotempty","不为空")
    ;
    private String methodsType;
    private String msg;

    public String getMethodsType() {
        return methodsType;
    }

    public void setMethodsType(String methodsType) {
        this.methodsType = methodsType;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    AssertMethodsType(String methodsType, String msg) {
        this.methodsType = methodsType;
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "AssertMethodsType{" +
                "methodsType='" + methodsType + '\'' +
                ", msg='" + msg + '\'' +
                '}';
    }

    /**
     * 转为数据
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, String>> toList() {
        List<Map<String, String>> list = new ArrayList<>();
        for (AssertMethodsType item : AssertMethodsType.values()) {
            Map<String, String> map = new HashMap<>();
            map.put("methodsType", item.getMethodsType());
            map.put("msg", item.getMsg());
            list.add(map);
        }
        return list;
    }

    public static AssertMethodsType getByValue(String methodsType){
        for (AssertMethodsType assertMethodsType:values()){
            if (methodsType.equals(assertMethodsType.getMethodsType())){
                return assertMethodsType;
            }
        }
        return null;
    }
}
